﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsProperties : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsProperties(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsProperties_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsProperties obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsProperties()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsProperties(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsProperties cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsProperties_cast(OdRxObject.getCPtr(pObj));
			OdGsProperties result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsProperties_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsProperties_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsProperties_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGsProperties createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsProperties_createObject();
			OdGsProperties result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setUnderlyingDrawable(OdGiDrawable pUnderlyingDrawable, OdGiContext ctx)
		{
			GlobalsPINVOKE.OdGsProperties_setUnderlyingDrawable(this.swigCPtr, OdGiDrawable.getCPtr(pUnderlyingDrawable), OdGiContext.getCPtr(ctx));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiDrawable underlyingDrawable()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsProperties_underlyingDrawable(this.swigCPtr);
			OdGiDrawable result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiDrawable)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isUnderlyingDrawableChanged(OdGiDrawable pUnderlyingDrawable)
		{
			bool result = GlobalsPINVOKE.OdGsProperties_isUnderlyingDrawableChanged(this.swigCPtr, OdGiDrawable.getCPtr(pUnderlyingDrawable));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool hasUnderlyingDrawable()
		{
			bool result = GlobalsPINVOKE.OdGsProperties_hasUnderlyingDrawable(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isUnderlyingDrawablePersistent()
		{
			bool result = GlobalsPINVOKE.OdGsProperties_isUnderlyingDrawablePersistent(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbStub underlyingDrawableId()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsProperties_underlyingDrawableId(this.swigCPtr);
			OdDbStub result = (intPtr == IntPtr.Zero) ? null : new OdDbStub(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiDrawable.DrawableType underlyingDrawableType()
		{
			OdGiDrawable.DrawableType result = (OdGiDrawable.DrawableType)GlobalsPINVOKE.OdGsProperties_underlyingDrawableType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsProperties.PropertiesType propertiesType()
		{
			OdGsProperties.PropertiesType result = (OdGsProperties.PropertiesType)GlobalsPINVOKE.OdGsProperties_propertiesType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsProperties propertiesForType(OdGsProperties.PropertiesType arg0)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsProperties_propertiesForType(this.swigCPtr, (int)arg0);
			OdGsProperties result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsProperties)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void update(OdGiDrawable pUnderlyingDrawable, OdGsViewImpl view, uint incFlags)
		{
			GlobalsPINVOKE.OdGsProperties_update__SWIG_0(this.swigCPtr, OdGiDrawable.getCPtr(pUnderlyingDrawable), OdGsViewImpl.getCPtr(view), incFlags);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void update(OdGiDrawable pUnderlyingDrawable, OdGsViewImpl view)
		{
			GlobalsPINVOKE.OdGsProperties_update__SWIG_1(this.swigCPtr, OdGiDrawable.getCPtr(pUnderlyingDrawable), OdGsViewImpl.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void display(OdGsBaseVectorizer view, OdGsPropertiesDirectRenderOutput pdro, uint incFlags)
		{
			GlobalsPINVOKE.OdGsProperties_display__SWIG_0(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdGsPropertiesDirectRenderOutput.getCPtr(pdro), incFlags);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void display(OdGsBaseVectorizer view, OdGsPropertiesDirectRenderOutput pdro)
		{
			GlobalsPINVOKE.OdGsProperties_display__SWIG_1(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdGsPropertiesDirectRenderOutput.getCPtr(pdro));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void display(OdGsBaseVectorizer view)
		{
			GlobalsPINVOKE.OdGsProperties_display__SWIG_2(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum PropertiesType
		{
			kViewport = 1,
			kBackground,
			kVisualStyle = 4,
			kRenderEnvironment = 8,
			kRenderSettings = 16,
			kDeviceSimple = 0,
			kDeviceBackground = 3,
			kDeviceNormal = 7,
			kDeviceRender = 255,
			kAll = 255
		}
	}
}
